const { db } = require("../config/dbConnect");
const StudentModel = db.model(
  "Student",
  {
    name: { type: String, default: "username" },
    age: { type: Number },
    sex: { type: String },
    hobbies: Array,
    class: String,
    score: Number,
  },
  "students"
);
const createStudentModel = (studConfig) => {
  const stuObj = new StudentModel(studConfig);
  return stuObj
    .save()
    .then((res) => res)
    .catch((err) => false);
};
const findStudent = () => {
  return StudentModel.find();
};
module.exports = {
  createStudentModel,
  findStudent,
};
